﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Threading;
using DG.Tweening;
using UnityEngine.UI;
using ComDevelop.ComTool;

using System;
namespace DevelopTools.UI
{
    public class UIManager : GameSingleton<UIManager>
    {
        public List<UIPanel> uiList;
        private void Awake()
        {
            Init();
        }
        private void Start()
        {
        }
        private void Init()
        {
            uiList = new List<UIPanel>();
        }
        /// <summary>
        /// 将需要显示的UI添加到uiList中
        /// </summary>
        /// <param name="list">需要显示的Panel列表</param>
        public void AddPanel(List<UIPanel> list)
        {
            for (int i = 0; i < list.Count; i++)
            {
                uiList.Add(list[i]);
            }
        }
        public void ShowUIPanel()
        {
            for (int i = 0; i < uiList.Count; i++)
            {
                uiList[i].gameObject.SetActive(true);
            }
        }
        public void ShowUIPanel(int index)
        {
            if (index >= uiList.Count)
            {
                return;
            }
            uiList[index].gameObject.SetActive(true);
        }
        public void ShowUIPanel(int[] indexs)
        {
            for (int i = 0; i < uiList.Count; i++)
            {
                for (int j = 0; j < indexs.Length; j++)
                {
                    if (i == indexs[j])
                    {
                        uiList[i].gameObject.SetActive(true);
                        continue;
                    }
                }
            }
        }
        public void ShowUIPanel(List<UIPanel> list)
        {
            for (int i = 0; i < uiList.Count; i++)
            {
                for (int j = 0; j < list.Count; j++)
                {
                    if (uiList[i] == list[j])
                    {
                        uiList[i].gameObject.SetActive(true);
                        continue;
                    }
                }
            }
        }

        public void HideUIPanel()
        {
            for (int i = 0; i < uiList.Count; i++)
            {
                uiList[i].gameObject.SetActive(false);
            }
        }
        public void HideUIPanel(int index)
        {
            if (index >= uiList.Count)
            {
                uiList[index].gameObject.SetActive(false);
            }
        }
        public void HideUIPanel(int[] indexs)
        {
            for (int i = 0; i < uiList.Count; i++)
            {
                for (int j = 0; j < indexs.Length; j++)
                {
                    if (i == indexs[j])
                    {
                        uiList[i].gameObject.SetActive(false);
                        continue;
                    }
                }
            }
        }
        public void HideUIPanel(List<UIPanel> list)
        {
            for (int i = 0; i < uiList.Count; i++)
            {
                for (int j = 0; j < list.Count; j++)
                {
                    if (uiList[i] == list[j])
                    {
                        uiList[i].gameObject.SetActive(false);
                        continue;
                    }
                }
            }
        }

    }
}